﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NiceManage.Common
{
    public  class DbHelper
    {
        public readonly static string connectionstring = "Database=niceweb;Data Source=127.0.0.1;User Id=root;Password=;pooling=false;CharSet=utf8;port=3306";
        public static SqlSugarClient GetInstance()
        {
            SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = connectionstring, DbType = DbType.MySql, IsAutoCloseConnection = true });
            db.Ado.IsEnableLogEvent = true;
            db.Ado.LogEventStarting = (sql, pars) => { Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(s => s.ParameterName, s => s.Value))); };
            return db;
        }
    }
}
